home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 235 / Issue 235 - September 2007 - DPCS0907DVD.ISO / Extras / NetObjects Fusion / NOF10.exe / data1.cab / FSI / lib / nof / util / AlertInvalidField.js next >
Encoding:
Text File  |  2007-04-11  |  2.6 KB  |  95 lines

  1. /****i* SOURCE_FILE/INFO
  2. *
  3. * NAME
  4. *  AlertInvalidField.js
  5. *
  6. * USAGE
  7. *  Part of Netobjects JavaScript Library.
  8. *
  9. * COPYRIGHT
  10. *  Copyright ⌐ 2002-2004 Website Pros, Inc.
  11. *  All Rights Reserved.
  12. *
  13. *  This is an unpublished work protected by Website Pros, Inc.
  14. *  as a trade secret, and is not to be used or disclosed except as
  15. *  expressly provided in a written license agreement executed by
  16. *  you and Website Pros, Inc.
  17. *
  18. *      <copyright@websitepros.com>
  19. *
  20. * NOTES
  21. *  JavaScript code.
  22. *****/
  23.     
  24. if (!IS_isModuleInitialized("IS.NOF.UTIL.AlertInvalidField"))
  25. {   
  26. /****h* NOF_JavaScript_Library/NOF.UTIL.AlertInvalidField
  27.     *
  28.     * NAME
  29.     *  NOF.UTIL.AlertInvalidField
  30.     *
  31.     * DESCRIPTION
  32.     * 
  33.     *
  34.     * External dependencies: 
  35.     ****/  
  36. /** 
  37. * AlertInvalidField
  38. */
  39.     function NOF_AlertInvalidField(_document, _alertTextContainer, _fields) {
  40.         this.__proto__ = NOF_AlertInvalidField.prototype;
  41.         
  42.         this.doc                 = _document;    
  43.         this.alertTextContainer = _alertTextContainer;
  44.         this.fields             = _fields;
  45.         
  46.         this.classNormal     = "formtext";
  47.         this.classError     = "errorformtext";
  48.         this.imageNormal     = "spacer.gif";
  49.         this.imageError      = "error_ph.gif";
  50.     }
  51.     
  52.     function NOF_AlertInvalidField_ProtoBuilder() {
  53.         var member = NOF_AlertInvalidField.prototype;
  54.         
  55.         member.notifyField = notifyField;
  56.         member.notifyAllFields = notifyAllFields;
  57.         member.alertTextContainer = null;
  58.         member.classNormal     = null;
  59.         member.classError     = null;
  60.         member.imageNormal     = null;
  61.         member.imageError      = null;    
  62.         
  63.         function notifyField(field, condition, alertText) {    
  64.             //var result = !eval(f + '.value.length');
  65.             var cls = (condition ? this.classError : this.classNormal);
  66.             var img = (condition ? this.imageError : this.imageNormal);
  67.             var t = field + 'Text';
  68.             var i = field + 'Image';
  69.             eval(t + '.className = "' + cls + '"');
  70.             eval(i + '.src = "./images/' + img + '"');
  71.             
  72.             if (alertText == null)
  73.                 alertText = "";
  74.             this.doc.setElementValue(this.alertTextContainer, alertText);
  75.         }
  76.         
  77.         function notifyAllFields(condition) {    
  78.             //var result = !eval(f + '.value.length');
  79.             var cls = (condition ? this.classError : this.classNormal);
  80.             var img = (condition ? this.imageError : this.imageNormal);
  81.             
  82.             for (var i = 0; i < this.fields.length; i++) {
  83.                 var text = this.fields[i] + 'Text';
  84.                 var image = this.fields[i] + 'Image';            
  85.                 eval(text + '.className = "' + cls + '"');
  86.                 eval(image + '.src = "./images/' + img + '"');    
  87.             }            
  88.         }
  89.     }
  90.     
  91.  
  92.     NOF_AlertInvalidField_ProtoBuilder();
  93.     //NOF.__proto__.AlertInvalidField = NOF_AlertInvalidField;
  94.     UTIL.__proto__.AlertInvalidField = NOF_AlertInvalidField;
  95. }